/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.kth.lwr.jeat.core;

/**
 *
 * @author davidev
 */

/**<p>
 * A class that defines a numeric operation with an argument (Y) on 
 * DataSouces. The first argument (X) and the resulting value (R) are of type V, 
 * while the second argument (Y) is a DataSource of type A. 
 * </p>
 * {@code R<V> = X<V> operation Y<A>}
 * <p>
 * A sequence of operations can then be executed like this:
 * </p>
 * <pre>
 * {@code 
 * 
 * //initial value
 * V retval=new V...
 * for (Operator<V,? extends DataSource> op : sequence) {
 *           retval=op.operate(retval, user);
 *       }
 *}
 * </pre>
 *
 * @param <A> the type of the second argument for the operation
 * @param <V> the type of the returning argument 
 */
abstract class Operator<V, A extends DataSource> {
    A argument;

    public Operator(A argument) {
        this.argument = argument;
    }
    
    /**
     * 
     * @return the (second) argument (Y) in the operation
     */
    protected A getArgument() {
        return argument;
    }
    
    /**Performs the operation and record usage of the DataSource argument (Y).
     * The dataSource argument is retrieved through the
     * {@link Operator.getArgument()} method.
     * 
     * @param operand first argument
     * @param dataUser the user of the DataSource
     * @return the value of the operation
     */

    abstract V operate(V operand, Activity dataUser);
    
    /**Performs the operation without recording usage of the DataSource argument 
     * (second argument). The dataSource argument is retrieved through the
     * {@link Operator.getArgument()} method.
     * 
     * @param operand
     * @return 
     */
    abstract V operate(V operand);
    
    
    /**Returns a sign that represent this operation (such as +, -, * etc)
     * 
     * @return operation sign
     */
    abstract String getOperationSign();
    
}
